﻿using InterLock.Common;
using System.Collections.Generic;
using System.Linq;

namespace InterLock.Helper
{
    public class CreateStationMapHelper
    {
        private static List<Equipment> list = FileReadHelper.GetList();

        /// <summary>
        /// 生成站场数据结构
        /// </summary>
        public static List<Equipment> CreateStationMap()
        {

            foreach (var eq in list)
            {
                if (eq.LZN != 0)
                {
                    eq.L = list.Where(s => s.N == eq.LZN).First();
                }
                if (eq.RZN != 0)
                {
                    eq.R = list.Where(s => s.N == eq.RZN).First();
                }
                if (eq.WGN != 0)
                {
                    eq.W = list.Where(s => s.N == eq.WGN).First();
                }
            }

            return list;
        }
    }
}
